﻿<UserControl xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"  
    x:Class="MyFloridaHouse.SilverlightOpenDistricts.xFileSaveAs"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400"
    Visibility="{Binding isFileSaveAsActive, Converter={StaticResource ConvertBoolToVisibility}}"
    >

    <Border Margin="0"  CornerRadius="20" BorderBrush="#FF549D9D"  BorderThickness="2"  
            Background="{StaticResource MainPageBackgroundBrush}"
            >

        <StackPanel>
            <Grid Margin="15">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <StackPanel Grid.Column="0">
                    <sdk:Label Content="District Plan Save As" Style="{StaticResource lblTitleStyle}" Margin="2,0,0,0" HorizontalAlignment="Left"/>
                </StackPanel>

            </Grid>

            <StackPanel  Orientation="Horizontal" HorizontalAlignment="Left" Margin="5">
                <Button x:Name="CancelButton" Content="Cancel" Command="{Binding CmdFileSaveAsCancel}" Width="75" Height="23" HorizontalAlignment="Right" Margin="5"  />
                <Button x:Name="OKButton" Content="OK" Command="{Binding CmdFileSaveAsOK}" Width="75" Height="23" HorizontalAlignment="Right" Margin="5"  />
                <Button x:Name="DeleteButton" Content="Delete"  Command="{Binding CmdIsolatedStorageDeleteFile}"  ></Button>
            </StackPanel>

            <StackPanel   Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Left" Margin="5">
                <RadioButton  Margin="2" Height="20"  Content="Local"            GroupName="StorageGroup" IsChecked="{Binding fileSaveFileSource, Mode=TwoWay, Converter={StaticResource ConvertEnumToBool}, ConverterParameter=LOCAL}" />
                <RadioButton  Margin="2" Height="20"  Content="Local Isolated"   GroupName="StorageGroup" IsChecked="{Binding fileSaveFileSource, Mode=TwoWay, Converter={StaticResource ConvertEnumToBool}, ConverterParameter=ISOLATED}" />
            </StackPanel>

            <StackPanel Visibility="{Binding isLocalSelected, Converter={StaticResource ConvertNotBoolToVisibility}}">
                <sdk:Label Grid.Row="1" Grid.Column="0"  HorizontalAlignment="Left"  Margin="5" Content="Enter Plan name..." />

                <TextBox x:Name="txtBx_districtPlanFileName"  Grid.Row="2" Grid.Column="0"  Style="{StaticResource TxtBxStyle}" HorizontalAlignment="Stretch" Margin="10" Text="{Binding fileSaveAsFileName, Mode=TwoWay, UpdateSourceTrigger=Explicit}" KeyUp="txtBx_districtPlanFileName_KeyUp" />

                <Border Margin="10,2"  CornerRadius="20" BorderBrush="DarkBlue"  
                        BorderThickness="1"  
                        Background="{StaticResource MainPageBackgroundBrush}"
                        >
                    <Grid Margin="15">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <ListBox Grid.Row="0" Grid.Column="0" Margin="0"   ItemsSource="{Binding fileSaveAsFileNameList}"  SelectedIndex="{Binding fileSaveAsFileNameListSelectedIndex, Mode=TwoWay}" Background="Azure" 
                                                     VerticalAlignment="Stretch"
                        HorizontalAlignment="Stretch">
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel UseLayoutRounding="True" />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.Template>
                                <ControlTemplate>
                                    <ScrollViewer>
                                        <ItemsPresenter />
                                    </ScrollViewer>
                                </ControlTemplate>
                            </ListBox.Template>
                            <ListBox.ItemTemplate >
                                <DataTemplate >
                                    <sdk:Label Content="{Binding fileName}"/>
                                </DataTemplate>
                            </ListBox.ItemTemplate>

                        </ListBox>

                    </Grid>
                </Border>
            </StackPanel>

        </StackPanel>
    </Border>
</UserControl>
